package com.szeldon.declatest.declaration.scenario.parts;

import java.util.ArrayList;
import java.util.List;

/**
 * Abstract superclass for all parts of scenario.
 * 
 * @author szeldon
 * 
 */
public abstract class ScenarioPartDeclaration {

    /** List of direct subparts of this part. */
    protected List<ScenarioPartDeclaration> partsList = new ArrayList<ScenarioPartDeclaration>();

    /**
     * Adds subpart for this part.
     * 
     * @param subpart
     *            Subpart to add.
     * @throws UnsupportedOperationException
     *             Thrown when this part doesn't support subparts.
     */
    public void addSubpart(ScenarioPartDeclaration subpart) throws IllegalArgumentException {
        ScenarioPartsHelper.tryAddingPartAfter(subpart, partsList);
    }

    /**
     * Returns type of this part.
     * 
     * @return Type of this part.
     */
    public abstract ScenarioPartsTypeEnum getPartType();

    /**
     * Returns list of subparts for this part.
     */
    public List<ScenarioPartDeclaration> getSubpartsList() {
        return partsList;
    }

    /**
     * Returns true if this part is a condition. False otherwise.
     */
    public abstract boolean isCondition();

}
